# -*- coding: UTF-8 -*-
import requests
import time

session=requests.session()

headers={
         "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
         "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
         "Accept-Encoding": "gzip,deflate,sdch"
         }
def getPid(url):
    r=session.get(url, headers=headers, verify=False)
    page=r.text
    page=page[page.index("newLemmaIdEnc:"):]
    page=page[:page.index("}")]
    pageId=page.replace("newLemmaIdEnc:", "").replace('"', "").strip()
    return pageId

def addVV(pid):
    starttime=time.time()
    endtime=time.time()
    session.get("http://baike.baidu.com/api/lemmapv?id="+pid+"&r="+str(endtime - starttime), headers=headers)
    
